package com.example.task.controller;


import com.example.task.dto.OrderCartDto;
import com.example.task.dto.OrderGoodsDto;
import com.example.task.service.intf.OrderService;
import com.example.task.vo.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/api/order/")
@Api(value = "实现订单相关操作",tags = "实现订单相关操作")
public class OrderController {
    @Autowired
    private OrderService service;

    //下单-购物车
    @PostMapping("saveco.do")
    public R save(@RequestBody OrderCartDto dto){
        return service.save(dto);
    }
    //下单-商详
    @PostMapping("savego.do")
    public R saveG(@RequestBody OrderGoodsDto dto){
        return service.save(dto);
    }
    //查询订单列表
    @GetMapping("list.do")
    public R all(long uid,int type){
        return service.queryMy(uid,type);
    }
    //查询订单详情
    @GetMapping("detail.do")
    public R detail(long oid){
        return service.queryDetail(oid);
    }
    //更改订单状态
    @GetMapping("change.do")
    public R change(long oid,int flag){
        return service.change(oid, flag);
    }
    //订单取消
    @GetMapping("cancel.do")
    public R cancel(long oid){
        return service.cancel(oid);
    }
}
